package com.ykzb.project.dao.impl;

import com.ykzb.base.dao.impl.BaseDaoImpl;
import com.ykzb.classify.dao.IClassifyDao;
import com.ykzb.classify.mapper.ClassifyMapper;
import com.ykzb.classify.model.Classify;
import com.ykzb.project.dao.ICategoryDao;
import com.ykzb.project.mapper.CategoryMapper;
import com.ykzb.project.model.CategoryInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@SuppressWarnings("restriction")
@Repository("categoryDao")
public class CategoryDaoImpl implements ICategoryDao
{
	@Autowired
	private CategoryMapper categoryMapper;


	@Override
	@Cacheable(value="category")
	public List<CategoryInfo> selectCategory(Map<String, Object> param) {
		return categoryMapper.selectCategory(param);
	}

	@Override
	@Cacheable(value="category")
	public Long selectIdByName(String name) throws Exception {
		if (name!=null){
			return categoryMapper.getIdByName(name);
		}
		return null;
	}

	@Override
	@Cacheable(value="category")
	public String selectNameById(Long id) throws Exception {
		if (id!=null){
			return categoryMapper.getNameById(id);
		}
		return null;
	}


}